Updated chef-solo deployment to work with current versions

Dominik Sander 11 years ago
parent
commit
a466688323

+ 4 - 0
Gemfile

@@ -63,3 +63,7 @@ group :development, :test do
63 63
   gem 'webmock', require: false
64 64
   gem 'coveralls', require: false
65 65
 end
66
+
67
+group :production do
68
+  gem 'unicorn'
69
+end

+ 7 - 0
Gemfile.lock

@@ -142,6 +142,7 @@ GEM
142 142
     kaminari (0.14.1)
143 143
       actionpack (>= 3.0.0)
144 144
       activesupport (>= 3.0.0)
145
+    kgio (2.9.2)
145 146
     kramdown (1.1.0)
146 147
     libv8 (3.16.14.3)
147 148
     macaddr (1.7.1)
@@ -195,6 +196,7 @@ GEM
195 196
       rake (>= 0.8.7)
196 197
       rdoc (~> 3.4)
197 198
       thor (>= 0.14.6, < 2.0)
199
+    raindrops (0.13.0)
198 200
     rake (10.2.2)
199 201
     rdoc (3.12.2)
200 202
       json (~> 1.4)
@@ -283,6 +285,10 @@ GEM
283 285
     uglifier (2.5.0)
284 286
       execjs (>= 0.3.0)
285 287
       json (>= 1.8.0)
288
+    unicorn (4.8.2)
289
+      kgio (~> 2.6)
290
+      rack
291
+      raindrops (~> 0.7)
286 292
     uuid (2.3.7)
287 293
       macaddr (~> 1.0)
288 294
     warden (1.2.3)
@@ -345,6 +351,7 @@ DEPENDENCIES
345 351
   twitter-stream!
346 352
   typhoeus (~> 0.6.3)
347 353
   uglifier (>= 1.0.3)
354
+  unicorn
348 355
   webmock
349 356
   weibo_2 (~> 0.1.4)
350 357
   wunderground (~> 1.1.0)

+ 3 - 0
deployment/.chef/knife.rb

@@ -0,0 +1,3 @@
1
+cookbook_path ["cookbooks", "site-cookbooks"]
2
+role_path     "roles"
3
+data_bag_path "data_bags"

+ 71 - 0
deployment/Cheffile.lock

@@ -0,0 +1,71 @@
1
+SITE
2
+  remote: http://community.opscode.com/api/v1
3
+  specs:
4
+    apt (2.3.8)
5
+    bluepill (2.3.1)
6
+      rsyslog (>= 0.0.0)
7
+    build-essential (2.0.0)
8
+    chef_handler (1.1.6)
9
+    dmg (2.2.0)
10
+    ohai (1.1.12)
11
+    rsyslog (1.12.2)
12
+    runit (1.5.10)
13
+      build-essential (>= 0.0.0)
14
+      yum (~> 3.0)
15
+      yum-epel (>= 0.0.0)
16
+    windows (1.30.2)
17
+      chef_handler (>= 0.0.0)
18
+    yum (3.2.0)
19
+    yum-epel (0.3.6)
20
+      yum (~> 3.0)
21
+
22
+GIT
23
+  remote: git://github.com/mdxp/nodejs-cookbook.git
24
+  ref: master
25
+  sha: e2415cd8c4e03dccf21d7ef6ca31e1c5c81467ca
26
+  specs:
27
+    nodejs (1.3.0)
28
+      apt (>= 0.0.0)
29
+      build-essential (>= 0.0.0)
30
+      yum-epel (>= 0.0.0)
31
+
32
+GIT
33
+  remote: git://github.com/opscode-cookbooks/git.git
34
+  ref: master
35
+  sha: 76b0f9bb08fdd9e2e201fd70b72298097accdf96
36
+  specs:
37
+    git (4.0.1)
38
+      build-essential (>= 0.0.0)
39
+      dmg (>= 0.0.0)
40
+      runit (>= 1.0)
41
+      windows (>= 0.0.0)
42
+      yum (~> 3.0)
43
+      yum-epel (>= 0.0.0)
44
+
45
+GIT
46
+  remote: git://github.com/opscode-cookbooks/mysql.git
47
+  ref: master
48
+  sha: a2ff53f0ca6deca75aebf6da55ac381194ec7728
49
+  specs:
50
+    mysql (5.1.9)
51
+
52
+GIT
53
+  remote: git://github.com/opscode-cookbooks/nginx.git
54
+  ref: master
55
+  sha: 05b3a613f53a0b05c96f9206c5d67aa420f337fb
56
+  specs:
57
+    nginx (2.6.3)
58
+      apt (~> 2.2)
59
+      bluepill (~> 2.3)
60
+      build-essential (~> 2.0)
61
+      ohai (~> 1.1)
62
+      runit (~> 1.2)
63
+      yum-epel (~> 0.3)
64
+
65
+DEPENDENCIES
66
+  git (>= 0)
67
+  mysql (>= 0)
68
+  nginx (>= 0)
69
+  nodejs (>= 0)
70
+  runit (>= 0)
71
+

+ 1 - 1
deployment/roles/huginn_production.json

@@ -10,7 +10,7 @@
10 10
 
11 11
 "default_attributes" : {
12 12
   "mysql": {
13
-    "server_root_password": "",
13
+    "server_root_password": "password",
14 14
     "server_repl_password": "",
15 15
     "server_debian_password": ""
16 16
   },

+ 0 - 58
deployment/site-cookbooks/huginn_production/files/default/Gemfile

@@ -1,58 +0,0 @@
1
-source 'https://rubygems.org'
2
-
3
-gem 'rails'
4
-gem 'rake'
5
-gem 'mysql2'
6
-gem 'devise'
7
-gem 'kaminari'
8
-gem 'bootstrap-kaminari-views'
9
-gem "rufus-scheduler", :require => false
10
-gem 'json', '>= 1.7.7'
11
-gem 'jsonpath'
12
-gem 'twilio-ruby'
13
-
14
-gem 'delayed_job', :git => 'https://github.com/wok/delayed_job' # Until the YAML issues are fixed in master.
15
-gem 'delayed_job_active_record', "~> 0.3.3" # newer was giving a strange MySQL error
16
-gem "daemons"
17
-# gem "delayed_job_web"
18
-group :production do
19
-  gem 'unicorn'
20
-end
21
-gem 'foreman'
22
-gem 'dotenv-rails', :groups => [:development, :test]
23
-
24
-group :assets do
25
-  gem 'sass-rails',   '~> 3.2.3'
26
-  gem 'coffee-rails', '~> 3.2.1'
27
-  gem 'uglifier', '>= 1.0.3'
28
-  gem 'select2-rails'
29
-  gem 'jquery-rails'
30
-end
31
-
32
-gem 'geokit-rails3'
33
-gem 'kramdown'
34
-gem "typhoeus"
35
-gem 'nokogiri'
36
-gem 'wunderground'
37
-
38
-gem "twitter"
39
-gem 'twitter-stream', '>=0.1.16'
40
-gem 'em-http-request'
41
-
42
-platforms :ruby_18 do
43
-  gem 'system_timer'
44
-  gem 'fastercsv'
45
-end
46
-
47
-group :development do
48
-  gem 'pry'
49
-end
50
-
51
-group :development, :test do
52
-  gem 'rspec-rails'
53
-  gem 'rspec'
54
-  gem 'shoulda-matchers'
55
-  gem 'rr'
56
-  gem 'webmock', :require => false
57
-  gem 'rake'
58
-end

+ 1 - 1
deployment/site-cookbooks/huginn_production/files/default/env.example

@@ -14,7 +14,7 @@ DATABASE_RECONNECT=true
14 14
 DATABASE_NAME=huginn_production
15 15
 DATABASE_POOL=5
16 16
 DATABASE_USERNAME=root
17
-DATABASE_PASSWORD=
17
+DATABASE_PASSWORD=password
18 18
 #DATABASE_HOST=your-domain-here.com
19 19
 #DATABASE_PORT=3306
20 20
 #DATABASE_SOCKET=/tmp/mysql.sock

+ 4 - 2
deployment/site-cookbooks/huginn_production/files/default/unicorn.rb

@@ -17,7 +17,8 @@ stdout_path "log/unicorn_err.log"
17 17
 pid '/home/huginn/shared/tmp/pids/unicorn.pid'
18 18
 
19 19
 before_fork do |server, worker|
20
-  ActiveRecord::Base.connection.disconnect!
20
+  defined?(ActiveRecord::Base) and
21
+    ActiveRecord::Base.connection.disconnect!
21 22
   old_pid = "#{server.config[:pid]}.oldbin"
22 23
   if File.exists?(old_pid) && server.pid != old_pid
23 24
     begin
@@ -29,5 +30,6 @@ before_fork do |server, worker|
29 30
 end
30 31
 
31 32
 after_fork do |server, worker|
32
-  ActiveRecord::Base.establish_connection
33
+  defined?(ActiveRecord::Base) and
34
+    ActiveRecord::Base.establish_connection
33 35
 end

+ 9 - 9
deployment/site-cookbooks/huginn_production/recipes/default.rb

@@ -14,7 +14,7 @@ group "huginn" do
14 14
   members ["huginn"]
15 15
 end
16 16
 
17
-%w("ruby1.9.1" "ruby1.9.1-dev" "libxslt-dev" "libxml2-dev" "curl" "libshadow-ruby1.8").each do |pkg|
17
+%w("ruby1.9.1" "ruby1.9.1-dev" "libxslt-dev" "libxml2-dev" "curl" "libshadow-ruby1.8" "libmysqlclient-dev" "libffi-dev").each do |pkg|
18 18
   package("#{pkg}")
19 19
 end
20 20
 
@@ -56,7 +56,7 @@ deploy "/home/huginn" do
56 56
     end
57 57
     directory("/home/huginn/shared/tmp/pids")
58 58
     directory("/home/huginn/shared/tmp/sockets")
59
-    %w(Procfile unicorn.rb Gemfile nginx.conf).each do |file|
59
+    %w(Procfile unicorn.rb nginx.conf).each do |file|
60 60
       cookbook_file "/home/huginn/shared/config/#{file}" do
61 61
       owner "huginn"
62 62
       action :create_if_missing
@@ -77,16 +77,16 @@ deploy "/home/huginn" do
77 77
       code <<-EOH
78 78
       export LANG="en_US.UTF-8"
79 79
       export LC_ALL="en_US.UTF-8"
80
-      ln -nfs /home/huginn/shared/config/Gemfile ./Gemfile
81 80
       ln -nfs /home/huginn/shared/config/Procfile ./Procfile
82 81
       ln -nfs /home/huginn/shared/config/.env ./.env
83 82
       ln -nfs /home/huginn/shared/config/unicorn.rb ./config/unicorn.rb
84
-      sudo cp /home/huginn/shared/config/nginx.conf /etc/nginx/ 
85
-      sudo bundle install
86
-      sed -i s/REPLACE_ME_NOW\!/$(sudo rake secret)/ .env
87
-      sudo rake db:create
88
-      sudo rake db:migrate
89
-      sudo rake db:seed
83
+      sudo cp /home/huginn/shared/config/nginx.conf /etc/nginx/
84
+      sudo bundle install --without=development --without=test
85
+      sed -i s/REPLACE_ME_NOW\!/$(sudo bundle exec rake secret)/ .env
86
+      sed -i s/config\.force_ssl\ \=\ true/config\.force_ssl\ \=\ false/ config/environments/production.rb
87
+      sudo bundle exec rake db:create
88
+      sudo bundle exec rake db:migrate
89
+      sudo bundle exec rake db:seed
90 90
       sudo foreman export upstart /etc/init -a huginn -u huginn -l log
91 91
       sudo start huginn
92 92
       EOH

+ 0 - 6
deployment/solo.rb

@@ -1,6 +0,0 @@
1
-file_cache_path           "/tmp/chef-solo"
2
-data_bag_path             "/tmp/chef-solo/data_bags"
3
-encrypted_data_bag_secret "/tmp/chef-solo/data_bag_key"
4
-cookbook_path             [ "/tmp/chef-solo/site-cookbooks",
5
-                            "/tmp/chef-solo/cookbooks" ]
6
-role_path                 "/tmp/chef-solo/roles"